package com.intelligence.tio.server;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.tio.server.AioServer;
import org.tio.server.ServerGroupContext;
import org.tio.server.intf.ServerAioHandler;
import org.tio.server.intf.ServerAioListener;
import com.intelligence.tio.common.Const;
import com.intelligence.tio.common.JsonPacket;
import com.intelligence.tio.common.TioSessionContext;


@SpringBootApplication
public class TioServerApplication {


    static ServerAioHandler<TioSessionContext, JsonPacket, Object> aioHandler = new TioServerAioHandler();
    static ServerAioListener<TioSessionContext, JsonPacket, Object> aioListener = new TioServerAioListener();
    static ServerGroupContext<TioSessionContext, JsonPacket, Object> serverGroupContext = new ServerGroupContext<>(aioHandler, aioListener);
    static AioServer<TioSessionContext, JsonPacket, Object> aioServer = new AioServer<>(serverGroupContext); //可以为空

    static String serverIp = null;
    static int serverPort = Const.PORT;

    public static void main(String[] args) {

        try {
            new PolicyServer().startPolicy();
            aioServer.start(serverIp, serverPort);
            SpringApplication
                    .run(TioServerApplication.class, args);
        } catch (Exception e) {

        }


    }
}
